<?

class PageTemplate extends Template {
	var $directory;
	function PageTemplate() {
		$this->directory = BASE_FULL_DIRECTORY . '/templates/';
	}
}

class SectionTemplate extends Template {
	var $directory;
	function SectionTemplate() {
		$this->directory = BASE_FULL_DIRECTORY . '/templates/sections/';
	}
}


class Template {
	
	var $file;
	var $args = array();
	
	function display() {
		$args = $this->args;	
		if (file_exists($this->directory.'/code/'.$this->file)) {
			include($this->directory.'/code/'.$this->file);
		}
		if (file_exists($this->directory.'/'.$this->file)) {
			include($this->directory.'/'.$this->file);
		}
	}
	
	function printImage($file, $alt = null) {
		if ($alt) {
			$alt = ' alt="' . $alt . '"';
		}
		$img = @getimagesize(BASE_FULL_DIRECTORY . TEMPLATES_IMAGES_DIRECTORY . '/' . $file);
		
		if ($img) {
			print('<img src="' . TEMPLATES_IMAGES_DIRECTORY . '/' . $file . '"' . $alt . ' width="' . $img[0] . '" height="' . $img[1] . '" />');
		}
	}
	
}

?>